package com.zhou.cloud.config;

import cn.hutool.core.date.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @descrition: redis配置
 * @author: zhouyongjun
 * @date: 2022/10/28
 **/
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "uuid")
@PropertySource("classpath:uuid.properties")
public class UuidProperties {
    //分区
    long zoneId;

    long centerId;
    //偏移量
    String offSetTimeDay="2020-01-01";
    //时间bit位数
    int dateTimeBitCount = 31;
    //分区bit位数
    int zoneBitCount = 0;
    //自增长bit位数
    int autoBitCount = 32;
    //总长度
    int maxBitCount = 64;
    public long getOffset() {
        long offset = DateUtil.parse(offSetTimeDay,"yyyy-MM-dd").getTime()/(24*60*60*1000);
        return offset;
    }


}
